function [ decibels_max, r_optim] = My_max_psnr( K, R, rmin, rmax, m)
%% 本质是：预嵌入的方法来优化参数
%MAX_PSNR calculation of PSNR and search for optimal radius from rmin-rmax
%   K - image; D - vector lenght; S - seed, m - implementation factor

F=K;

%%Transformation in Fourier domain >> M - magnitude, P - phase 
[M,P] = InputProc(K);

%initialization 
decibels_max=0;
r_optim=0;

%main loop for radius
for r=rmax:-1:rmin%由大向小
    
%vector embedding ,E_mark为最后生成的含秘幅值谱
[E_mark] = Embed1(M,R,m,r);

%return to spatial domain 
W_i = ifft2(ifftshift(E_mark).*exp(1i*P));%一句话实现逆DFT转换，学习一下，相位谱基本不变

%image adjastment of max and min values with the original 
W_i = uint8(W_i);%复数值直接取实部
W_i = imadjust(W_i,[single(min(min(W_i)))/255 ; single(max(max(W_i)))/255] , [single(min(min(F)))/255 ; single(max(max(F)))/255] );
% imadjust 对图像I进行灰度调整,single只是单精度数据类型
%Determing PSNR
error_diff1 = single(F) - single(W_i);
decibels = 20*log10(255/(sqrt(mean2(error_diff1.^2))));%相当于是个失真代价了，越大越好，与失真呈反比
if (decibels<=inf) && (decibels>decibels_max) 
    decibels_max=decibels;
    r_optim=r; 
    
end
end
end

